package sortColors75;

public class SortColors {
    public void sortColors(int[] nums) {
        int p0 = 0;
        int p2 = nums.length-1;
        int i=0;
        while (i<=p2){
            if(nums[i] == 0){
                swap(nums,i,p0);
                p0++;
                i++;
            }else if(nums[i] == 1){
                i++;
            }else {
                swap(nums,i,p2);
                p2--;
            }
        }
    }

    public void swap(int [] a,int i,int j){
        int temp = a[i];
        a[i] = a[j];
        a[j] = temp;
    }



}
